<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache,no-store,must-revalidate">
    <meta http-equiv="Cache" content="no-cache">
		<title>新增页面</title>
		<link rel="stylesheet" href="../../../component/pear/css/pear.css" />
	</head>
	<body>
		<form class="layui-form" action="" lay-filter="form-filter">
			<div class="mainBox">
				<div class="main-container">
					

					<div class="layui-form-item">
						<label class="layui-form-label">设备号</label>
						<div class="layui-input-block" >
							<input type="text" name="machineNo" lay-verify="required" autocomplete="off" placeholder="请输入"
								class="layui-input" disabled style="background-color: #e8ecef;">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">记录时间</label>
						<div class="layui-input-block">
							<input type="text" name="recordTimeDT" lay-verify="required" autocomplete="off" placeholder="请输入"
								class="layui-input" disabled  style="background-color: #e8ecef;">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">计划产量kpcs</label>
						<div class="layui-input-block">
							<input type="number" name="planOutput" lay-verify="required" autocomplete="off" placeholder="请输入"
								class="layui-input" >
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">实际产量kpcs</label>
						<div class="layui-input-block">
							<input type="number" name="actualOutput" lay-verify="required" autocomplete="off" placeholder="请输入"
								class="layui-input" >
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">不良数pcs</label>
						<div class="layui-input-block">
							<input type="number" name="defect" lay-verify="required" autocomplete="off" placeholder="请输入"
								class="layui-input" >
						</div>
					</div>
					
					<div class="layui-form-item">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-block">
							<input type="text" name="recordRemark" autocomplete="off" placeholder="请输入"
								class="layui-input" >
						</div>
					</div>
					

				</div>
			</div>
			<div class="bottom">
				<div class="button-container">
					<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="shiftCapaRecordEdit">
						<i class="layui-icon layui-icon-ok"></i>
						提交
					</button>
					<!-- <button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button> -->
				</div>
			</div>
		</form>
		<script src="../../../component/layui/layui.js"></script>
		<script src="../../../component/pear/pear.js"></script>
    <script src="../../../lay-ext/dayjs.min.js"></script>

		<script type="text/javascript">
			// 加载自定义模块,检查浏览器和token
			layui.extend({
        myheader: "{/}/lay-ext/myheader",
      });
			
			
			layui.use(['form', 'jquery','myheader','layer','laytpl','select'], function() {
				let form = layui.form;
				let $ = layui.jquery;
				let myheader = layui.myheader;
				let layer = layui.layer;
				let laytpl = layui.laytpl;
				let select = layui.select;

        // 定义全局 ajax的请求头
        myheader.ajaxGlobal(myheader.checkToken().tokenValue);


				const fuData=layui.sessionData('fu2zi').fuinfo

				// 清空父传子时临时用的session对象
				layui.sessionData('fu2zi',null)

				if(dayjs(fuData.shiftCapacityRecord.recordTimeDT).hour()==20){
					fuData.shiftCapacityRecord.recordTimeDT = dayjs(fuData.shiftCapacityRecord.recordTimeDT).format('YYYY-MM-DD') + " 二值" 
				}
				if(dayjs(fuData.shiftCapacityRecord.recordTimeDT).hour()==8){
					fuData.shiftCapacityRecord.recordTimeDT = dayjs(fuData.shiftCapacityRecord.recordTimeDT).format('YYYY-MM-DD') + " 一值" 
				}

				form.val("form-filter",{
					"machineNo": fuData.shiftCapacityRecord.machineNo,
					"recordTimeDT": fuData.shiftCapacityRecord.recordTimeDT,
					"planOutput" : fuData.shiftCapacityRecord.planOutput,
					"actualOutput" : fuData.shiftCapacityRecord.actualOutput,
					"defect": fuData.shiftCapacityRecord.defect,
					"recordRemark" : fuData.shiftCapacityRecord.recordRemark
				})
			
				form.on('submit(shiftCapaRecordEdit)', function(data) {

					$.ajax({
						url: parent.layui.myheader.baseUrl()+ '/shiftcaparecord/uptShiftCapacityRecord',
						data: JSON.stringify({
							shiftCapaRecordID: fuData.shiftCapacityRecord.shiftCapaRecordID,
							planOutput:data.field.planOutput,
							actualOutput: data.field.actualOutput,
							defect:data.field.defect,
							recordRemark:data.field.recordRemark
						}),
						contentType:'application/json;charset=UTF-8',
						type: 'post',
						success: function(res) {
							if (res.code==200) {
								layer.msg("已保存", {
									time: 1000
								}, function() {
									parent.layer.close(parent.layer.getFrameIndex(window
										.name)); //关闭当前页
									parent.layui.table.reloadData('shift-capacity-record-table',{
										scrollPos: 'fixed'  // 保持滚动条位置不变 - v2.7.3 新增
									});
								});
							} else {
								layer.msg("保存失败", {
									time: 1000
								});
							}
						}
					})
					return false;
				});
			
			})
		</script>

	</body>
</html>
